VERSION 5.00
Object = "{0BA686C6-F7D3-101A-993E-0000C0EF6F5E}#1.0#0"; "threed32.ocx"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "Comdlg32.ocx"
Object = "{20C62CAE-15DA-101B-B9A8-444553540000}#1.1#0"; "MSMAPI32.OCX"
Begin VB.Form frmEnviarCorreo 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Enviar Correo"
   ClientHeight    =   2880
   ClientLeft      =   3840
   ClientTop       =   1680
   ClientWidth     =   5865
   Icon            =   "frmEnviarCorreo.frx":0000
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2880
   ScaleWidth      =   5865
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  'CenterScreen
   Begin Threed.SSCommand cmdEnviar 
      Height          =   375
      Left            =   3330
      TabIndex        =   8
      Top             =   2400
      Width           =   1185
      _Version        =   65536
      _ExtentX        =   2090
      _ExtentY        =   661
      _StockProps     =   78
      Caption         =   "&Enviar"
      ForeColor       =   4194304
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      RoundedCorners  =   0   'False
      Outline         =   0   'False
      AutoSize        =   1
   End
   Begin MSComDlg.CommonDialog cdArchivo 
      Left            =   135
      Top             =   75
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.TextBox txtAdjunto 
      Height          =   315
      Left            =   1350
      TabIndex        =   3
      Top             =   1920
      Width           =   4020
   End
   Begin VB.TextBox txtPara 
      Height          =   315
      Left            =   1350
      TabIndex        =   2
      Top             =   1515
      Width           =   4455
   End
   Begin MSMAPI.MAPISession MAPIS 
      Left            =   30
      Top             =   1365
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      DownloadMail    =   0   'False
      LogonUI         =   -1  'True
      NewSession      =   0   'False
   End
   Begin MSMAPI.MAPIMessages MAPIM 
      Left            =   45
      Top             =   615
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      AddressEditFieldCount=   1
      AddressModifiable=   0   'False
      AddressResolveUI=   0   'False
      FetchSorted     =   0   'False
      FetchUnreadOnly =   0   'False
   End
   Begin Threed.SSCommand cmdCancelar 
      Height          =   375
      Left            =   4590
      TabIndex        =   10
      Top             =   2400
      Width           =   1185
      _Version        =   65536
      _ExtentX        =   2090
      _ExtentY        =   661
      _StockProps     =   78
      Caption         =   "&Cancelar"
      ForeColor       =   4194304
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      RoundedCorners  =   0   'False
      Outline         =   0   'False
      AutoSize        =   1
   End
   Begin VB.TextBox txtTitulo 
      Height          =   330
      Left            =   1350
      TabIndex        =   0
      Text            =   "Solicitud de Cotizacion"
      Top             =   75
      Width           =   4440
   End
   Begin VB.TextBox txtAsunto 
      Height          =   960
      Left            =   1350
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   1
      Top             =   480
      Width           =   4440
   End
   Begin Threed.SSCommand cmdAdjuntar 
      Height          =   270
      Left            =   5355
      TabIndex        =   9
      Top             =   1935
      Width           =   240
      _Version        =   65536
      _ExtentX        =   423
      _ExtentY        =   476
      _StockProps     =   78
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial Black"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Picture         =   "frmEnviarCorreo.frx":000C
   End
   Begin VB.Label Label4 
      AutoSize        =   -1  'True
      Caption         =   "Asunto"
      Height          =   195
      Left            =   675
      TabIndex        =   7
      Top             =   585
      Width           =   495
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      Caption         =   "Archivo Adjunto"
      Height          =   195
      Left            =   45
      TabIndex        =   6
      Top             =   1980
      Width           =   1125
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "Para"
      Height          =   195
      Left            =   840
      TabIndex        =   5
      Top             =   1455
      Width           =   330
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "Titulo"
      Height          =   195
      Left            =   780
      TabIndex        =   4
      Top             =   105
      Width           =   390
   End
End
Attribute VB_Name = "frmEnviarCorreo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public intCantidad As Integer

Private Sub cmdAdjuntar_Click()
    cdArchivo.ShowOpen
    txtAdjunto.Text = cdArchivo.FileName
End Sub

Private Sub cmdCancelar_Click()
    Unload Me
End Sub

Private Sub cmdEnviar_Click()
Dim strCadena As String, intPos As Integer, strEmail As String, _
    intFila As Integer, intEmails As Integer
    On Error GoTo Falla

    If Len(txtAsunto.Text) = 0 Then MsgBox "Ingrese el Asunto": Exit Sub
    If Len(txtPara.Text) = 0 Then MsgBox "Ingrese la Direccion": Exit Sub
    
    MAPIS.DownLoadMail = False
    MAPIS.LogonUI = True 'Si el Outloock es el correo predeterminado debe ser false
    MAPIS.SignOn
    If MAPIS.SessionID = 0 Then MAPIS.SessionID = -1
    MAPIM.SessionID = MAPIS.SessionID
    MAPIM.MsgIndex = -1
    MAPIM.MsgSubject = txtTitulo.Text
    
    strCadena = Trim$(txtPara.Text)
    
    intEmails = BuscarCantidadCaracter(strCadena)
    
    For intFila = 0 To intEmails
        
        intPos = InStr(strCadena, ";")
        If intPos = 0 Then
            strEmail = strCadena
        Else
            strEmail = Mid(strCadena, 1, (intPos - 1))
        End If
        
        MAPIM.RecipDisplayName = strEmail
        
        strCadena = Mid(strCadena, intPos + 1, Len(strCadena))
        
        MAPIM.MsgNoteText = txtAsunto.Text
        If txtAdjunto.Text <> "" Then MAPIM.AttachmentPathName = txtAdjunto.Text
        
        MAPIM.Send (0)  '1=muestra el Outloock / 0=Envia directo
    Next intFila
        
    GoTo Fin
Falla:
    
    MsgBox Err.Description, vbCritical
Fin:
    On Error Resume Next
    MAPIS.SignOff
End Sub

Private Sub txtTitulo_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtAsunto.SetFocus
End Sub
